﻿using Base.Infrastructure.Dto.Request.Login;
using Base.Infrastructure.Dto.Response;
using Base.Infrastructure.Tools;
using Base.Service.EFCore.Interface;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;

namespace Base.Api.Admin.Controllers
{
    [Route("api/[controller]/[action]")]
   /* [ApiExplorerSettings(GroupName = "Login")]*///分组
    [ApiController]
    public class LoginController : BaseController
    {
        private readonly Service.Interface.ILoginService _loginService;

        public LoginController(Base.Service.Interface.ILoginService loginService)
        {
            _loginService = loginService;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        [Filters.ActionLog(group = "登录", name = "用户登录")]//日志记录
        [Filters.ResultAttrbute]
        public IActionResult Logins(LoginRequestDto dto) {
            dto.code = Config.GUID();
            dto.ip = this.GetIp();
            var result = _loginService.Logins(dto);
            return Ok(result);
        }
    }
}
